package com.bfl.sa.sys.organization.service;

import com.bfl.sa.common.plugin.serivce.BaseTreeableService;
import com.bfl.sa.sys.organization.entity.Organization;
import com.bfl.sa.sys.organization.mapper.OrganizationMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.Set;


@Service
public class OrganizationService extends BaseTreeableService<Organization, Long> {

    /**
     * 过滤仅获取可显示的数据
     */
    public void filterForCanShow(Set<Long> organizationIds, Set<Long[]> organizationJobIds) {

        Iterator<Long> iterator1 = organizationIds.iterator();
        while (iterator1.hasNext()) {
            Long id = iterator1.next();
            Organization o = findOne(id);
            if (o == null || Boolean.FALSE.equals(o.getShow())) {
                iterator1.remove();
            }
        }

        Iterator<Long[]> iterator2 = organizationJobIds.iterator();
        while (iterator2.hasNext()) {
            Long id = iterator2.next()[0];
            Organization o = findOne(id);
            if (o == null || Boolean.FALSE.equals(o.getShow())) {
                iterator2.remove();
            }
        }

    }
}
